package com.example.student.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.student.entity.EduCourseSelection;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface EduCourseSelectionMapper extends BaseMapper<EduCourseSelection> {
    
    /**
     * 检查学生是否有未选的必修课程
     */
    @Select("SELECT EXISTS (" +
            "SELECT 1 FROM edu_course c " +
            "LEFT JOIN edu_course_selection cs ON c.id = cs.course_id AND cs.student_id = #{studentId} " +
            "WHERE c.course_type = 1 " + // 1表示必修课
            "AND cs.id IS NULL)")
    boolean hasUnselectedRequiredCourses(Long studentId);
} 